/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.vng.zing.zprofilefrontend.handlers;

import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;

/**
 *
 * @author namhh
 */
public class FilterHandler implements Filter {

    @Override
    public void init(FilterConfig fc) throws ServletException {
    }

    @Override
    public void doFilter(ServletRequest req, ServletResponse sr1, FilterChain fc) throws IOException, ServletException {

    HttpServletRequest httpServletRequest = (HttpServletRequest)req;

    if ("/".equals(httpServletRequest.getPathInfo())) {
        httpServletRequest.getRequestDispatcher("/login").forward(req, sr1);
    } else {
        fc.doFilter(req, sr1);
    }
       
    }

    @Override
    public void destroy() {
    }

}
